<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/9/25 0025
  Time: 15:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"  language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--要设置变量得先把变量存在作用域中,根据key值得到变量--%>
<%! int a = 10;
int b= 20;
int c = 30;
int d = 40;
int[] ints = {0,1,3,5,9,8};%>
<% pageContext.setAttribute("a2",a);
pageContext.setAttribute("a4",ints);%>

${a2}

<%ArrayList list = new ArrayList();
 pageContext.setAttribute("a3",list);
list.add("where are you?");
%>
${a3[0]}
${a4[0]}
<% Map map = new HashMap();
map.put("k1","love");%>
<% pageContext.setAttribute("a5",map);%>

${a5.k1} <%--EL表达式中map集合的取值方式--%>
<%--EL表达式中相同k,展示结果作用域从小到大展示,pagecontext最优先,当然也可以取指定作用域的--%>
<% request.setAttribute("a1",a);%>
<%session.setAttribute("a1",b);%>
<%application.setAttribute("a1",c);%>
<%pageContext.setAttribute("a1",d);%>
${sessionScope.a1}
<%--
<%out.print("nizai哪里呀");%>
<%out.append("nizai哪里呀");%>
<%out.append("我在等你呀");%>
<!--<% out.print("<script>alert('你在哪里呀?')</script>");%> --><!--alert 只能在script中使用-->
<%=20>30%>
${20>39}
${20>30?"你在哪里":"我在这里"}
--%>
你早干嘛去了?
</body>
</html>
